package com.example.controller;


import com.example.common.result.PageResult;
import com.example.common.result.Result;
import com.example.entity.vo.BomcaVo;
import com.example.entity.vo.InvmbVo;
import com.example.service.BomcaService;
import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.xml.transform.Source;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LiangPandeng
 * @since 2024-02-26
 */
@RestController
@RequestMapping("/api/bomca")
@Api( tags = "BOM表接口")
public class BomcaController {

    @Resource
    private BomcaService bomcaService;


    @ApiOperation("品号基本信息查询")
    @GetMapping("/invmbSelect")
    public Result<PageResult> InvmbSelectPage(@RequestParam(defaultValue = "1") Integer current,
                                              @RequestParam(defaultValue = "10") Integer size,
                                              @RequestParam(required = false) String ph,
                                              @RequestParam(required = false) String pm,
                                              @RequestParam(required = false)  Character zt){

        if (zt == null) System.out.println("kong");
        System.out.println(zt);
        Page<InvmbVo> invmbPage = bomcaService.invmbPage(current, size,ph,pm,zt);
        System.out.println("状态：" + zt);
        PageResult pageResult =  new PageResult();
        pageResult.setRecords(invmbPage.getResult());
        pageResult.setTotal(invmbPage.getTotal());
        return Result.success(pageResult);
    }

    @ApiOperation("BOM展阶")
    @GetMapping("/select")
    @ApiImplicitParam(name = "ph",value = "品号")
    public Result<List<BomcaVo>> select(@RequestParam() String ph){

        List<BomcaVo> list = bomcaService.selectByPh(ph);
        return Result.success(list);
    }
}
